package thisgame;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import thisgame.model.Collidable;
import thisgame.model.Direction;
import thisgame.model.Character;

/**
 * 특정 캐릭터를 방향키로 움직일 수 있게 하는 컨트롤러.
 * 
 * @author Kroisse
 *
 */
public class KeyMoveController implements KeyListener {

	/*
	 * (non-javadoc)
	 */
	private Character character;

	/*
	 * (non-javadoc)
	 */
	private Collidable collidable;

	/**
	 * Getter of the property <tt>character</tt>
	 * 
	 * @return Returns the character.
	 * 
	 */

	public Character getCharacter() {
		return character;
	}

	/**
	 * Getter of the property <tt>collidable</tt>
	 * 
	 * @return Returns the collidable.
	 * 
	 */

	public Collidable getCollidable() {
		return collidable;
	}

	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		switch (e.getKeyCode()) {
		case KeyEvent.VK_UP:
			character.move(Direction.UP);
			System.out.println("up");
			break;
		case KeyEvent.VK_DOWN:
			character.move(Direction.DOWN);
			System.out.println("down");
			break;
		case KeyEvent.VK_RIGHT:
			character.move(Direction.RIGHT);
			System.out.println("right");
			break;
		case KeyEvent.VK_LEFT:
			character.move(Direction.LEFT);
			System.out.println("left");
			break;
		}
	}

	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub

	}

	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub

	}

	/**
	 * Setter of the property <tt>character</tt>
	 * 
	 * @param character
	 *            The character to set.
	 * 
	 */
	public void setCharacter(Character character) {
		this.character = character;
	}

	/**
	 * Setter of the property <tt>collidable</tt>
	 * 
	 * @param collidable
	 *            The collidable to set.
	 * 
	 */
	public void setCollidable(Collidable collidable) {
		this.collidable = collidable;
	}

}
